# 引入requests模块
import requests

# 准备要爬取的网址
url = 'https://www.daomubiji.com/'
# 设置请求头，用户代理（模拟真实浏览器）
headers = {
  'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50'
}
# 发送请求
r = requests.get(url=url,headers=headers)
print(r)
# 获取网页的源代码
# print(r.text)
# 将获取的网页源代码写入到文件daomu.html
f = open('daomu.html','w',encoding='utf-8')
# 获取的源代码写入文件
f.write(r.text)